﻿using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using HNAlbum.Logic.Entity;

namespace HNAlbum.Component.Pikachoose
{
    /// <summary>
    /// Inplement Pikachoose slider http://pikachoose.com/
    /// </summary>
    public class PikachooseSlider : Panel
    {
        /// <summary>
        /// Instanciate a Pikachoose slider
        /// </summary>
        public PikachooseSlider(string instanceName, string galleryId)
        {
            //Pikachoose class
            this.Attributes.Add("class", "pikachoose");

            HtmlGenericControl pikaChoose = new HtmlGenericControl("ul");
            pikaChoose.Attributes.Add("id", instanceName);
            pikaChoose.Attributes.Add("class", "jcarousel-skin-pika");
            this.Controls.Add(pikaChoose);

            HNAlbumData album = new HNAlbumData(galleryId);
            album.Load();

            foreach (KeyValuePair<string, HNAlbumPhoto> item in album.PhotoCollection)
            {
                PikachooseItem pika = new PikachooseItem(item.Value.Name, item.Value.Caption);
                pikaChoose.Controls.Add(pika);
            }

        }
    }
}